import {createStore} from 'vuex'
import preference from "@/plugins/preference";

export default createStore({
    state: {
        todos: [{id: '123', status: 'OK'}],
        login: false,
        isCollapse: preference.get('isCollapse') || false
    },
    mutations: {
        flip: state => {
            state.isCollapse = !state.isCollapse
            preference.set('isCollapse', state.isCollapse)
        }
    },
    actions: {},
    modules: {},
    getters: {
        getTodoById: (state) => (id: string) => {
            return state.todos.find(x => x.id === id)
        },
        collapse: state => state.isCollapse
    }
})
